class Player:
    #hp 代表⾎量，power 代表攻击⼒，给默认值
    hp = 100
    power = 10

    def __init__(self, hp, power):
        self.hp = hp
        self.power = power

    def fight(self, enemy_hp, enemy_power):
        #英雄最终的⾎量 = 英雄hp属性 - 敌⼈的攻击⼒enemy_power
        #敌⼈最终的⾎量 = 敌⼈的⾎量enemy_hp-英雄的power属性
        self.hp = self.hp-enemy_power
        enemy_final_hp = enemy_hp - self.power

        #血量比较，并输出对应结果
        if self.hp > enemy_final_hp:

            print(f"我的血量是{self.hp}，敌人的血量是{enemy_final_hp}")
            print("英雄获胜")

        else:
            if self.hp == enemy_final_hp:
                print(f"我的血量是{self.hp}，敌人的血量是{enemy_final_hp}")
                print("打成平手")
            else:
                print(f"我的血量是{self.hp}，敌人的血量是{enemy_final_hp}")
                print("敌人获胜")#血量比较，并输出对应结果

#角色实例化
timo = Player(100, 10)
police = Player(90, 5)
# timo.fight(police.hp,police.power)
# police.fight(timo.hp,timo.power)power
#当其中一方血量小于0结束游戏
while timo.hp >= 0 and police.hp >= 0:
    timo.fight(police.hp, police.power)
    police.fight(timo.hp, timo.power)

